/********************************************************************************
* File Name:	toolbox.cpp
* Description:	第3章 实例10：ToolBox的实例
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
*
********************************************************************************/
#include "toolbox.h"
#include <QGroupBox>
#include <QVBoxLayout>
#include <QPushButton>

toolbox::toolbox(QWidget *parent) :
    QToolBox(parent)
{
    this->setWindowTitle("ToolBox");
    QGroupBox *groupBox1 = new QGroupBox;
        QGroupBox* groupBox2 = new QGroupBox();
        QGroupBox* groupBox3 = new QGroupBox();
        /************Layout************/
        this->toolButton1_1 = new QToolButton;
        this->toolButton1_1->setText(tr("Vertical Layout"));
        this->toolButton1_1->setAutoRaise(true);

        this->toolButton1_2 = new QToolButton;
        this->toolButton1_2->setText(tr("Horizontal Layout"));
        this->toolButton1_2->setAutoRaise(true);

        this->toolButton1_3 = new QToolButton;
        this->toolButton1_3->setText(tr("Grid Layout"));
        this->toolButton1_3->setAutoRaise(true);

        this->toolButton1_4 = new QToolButton;
        this->toolButton1_4->setText(tr("Form Layout"));
        this->toolButton1_4->setAutoRaise(true);


        /*************Spacers***************/
        this->toolButton2_1 = new QToolButton;
        this->toolButton2_1->setText(tr("Horizontal Spacer"));
        this->toolButton2_1->setAutoRaise(true);

        this->toolButton2_2 = new QToolButton;
        this->toolButton2_2->setText(tr("Vertical Spacer"));
        this->toolButton2_2->setAutoRaise(true);
        /************Buttons*************************/
        this->toolButton3_1 = new QToolButton;
        this->toolButton3_1->setText(tr("Push Button"));
        this->toolButton3_1->setAutoRaise(true);

        this->toolButton3_2 = new QToolButton;
        this->toolButton3_2->setText(tr("Tool Button"));
        this->toolButton3_2->setAutoRaise(true);

        this->toolButton3_3 = new QToolButton;
        this->toolButton3_3->setText(tr("Radio Button"));
        this->toolButton3_3->setAutoRaise(true);

        this->toolButton3_4 = new QToolButton;
        this->toolButton3_4->setText(tr("Check Box"));
        this->toolButton3_4->setAutoRaise(true);

        QVBoxLayout* layout1 = new QVBoxLayout(groupBox1);
        layout1->setMargin(10);
        layout1->setAlignment(Qt::AlignLeft);
        layout1->addWidget(toolButton1_1);
        layout1->addWidget(toolButton1_2);
        layout1->addWidget(toolButton1_3);
        layout1->addWidget(toolButton1_4);
        layout1->addStretch();

        QVBoxLayout* layout2 = new QVBoxLayout(groupBox2);
        layout2->setMargin(10);
        layout2->setAlignment(Qt::AlignLeft);
        layout2->addWidget(toolButton2_1);
        layout2->addWidget(toolButton2_2);
        layout2->addStretch();

        QVBoxLayout* layout3 = new QVBoxLayout(groupBox3);
        layout3->setMargin(10);
        layout3->setAlignment(Qt::AlignLeft);
        layout3->addWidget(toolButton3_1);
        layout3->addWidget(toolButton3_2);
        layout3->addWidget(toolButton3_3);
        layout3->addWidget(toolButton3_4);
        addItem(groupBox1, tr("Layouts"));
        addItem(groupBox2, tr("Spacers"));
        addItem(groupBox3, tr("Buttons"));
}
